<section class="hauptseite register_page">
	<div class="container">
		<div class="row">
		<h2>Payment</h2>
	<?php
	$currencySymbol = cr("DealConfig.currency_symbol");
	$taxPercent = cr("DealConfig.tax");
	if(!$taxPercent)
	{
		$taxPercent = 0;
	}
	$options = array();
	for($i = 1; $i <= 35; $i++)
	{
		$options[$i] = $i;
	}
	echo $form->create('DealOrder',array('url'=>'/'.$this->params['url']['url'],'id'=>'buy_deal_form','enctype'=>'multipart/form-data'));
	?>
<table cellspacing="0" class="checkoutOrder table">

	<thead>
         

<tr class="header">
    <th class="description"><?php echo __("Your chosen deal option"); ?></th>
    <th class="quantity"><?php echo __("Quantity"); ?></th>
    <th class="multipliedBy">&nbsp;</th>
    <th class="priceSingle"><?php echo __("Single amount"); ?></th>
    <th class="priceSum"><?php echo __("Total"); ?></th>
</tr>
        </thead>
<tbody>

<tr class="data altrow">
    <td class="description">
		<?php echo $deal['Deal']['title'] ?>
    </td>
    <td class="quantity">
        <?php 
		echo $form->input('quantity',array('label'=>false,'default'=>1,'options'=>$options,'div'=>false));
		?>
	</td>
    <td class="multipliedBy"><b>x</b></td>
    <td class="priceSingle">
		<span id="singleDealAmount" class="order_details">
			<?php echo $currencySymbol."".$deal['Deal']['finalPrice']; ?>
		</span>
    </td>
    <td class="priceSum">
		<span id="totalDealAmount" class="order_details">
			<?php echo $currencySymbol."".$deal['Deal']['finalPrice']; ?>
		</span>
    </td>
</tr>
<?php //echo  ?>
<tr class="data trTax">
    <td colspan="4" class="taxText"><b><?php echo sprintf(__("Tax @ %s%%"),$taxPercent); ?></b></td>
    <td class="tax">
    	<b>
			<span id="finalTaxAmount">
				<?php echo $currencySymbol."".(($deal['Deal']['finalPrice'] / 100) * $taxPercent) ; ?>
			</span>
		</b>
    </td>
</tr>
<tr class="data trSumTotal">
    <td colspan="4" class="priceSumTotalText"><b><?php echo __("Total amount"); ?></b></td>
    <td class="priceSumTotal">
    	<b>
			<span id="finalDealAmount">
				<?php echo $currencySymbol."".(($deal['Deal']['finalPrice'] * ($taxPercent))/ 100); ?>
			</span>
		</b>
    </td>
</tr>
</tbody></table>
	

<div class="pay_button">
	<?php 
	echo $form->end(array('label'=>__('Proceed to pay'), 'class'=>'bt_submit'));
	?>
<!-- PayPal Logo --><img  src="https://www.paypal.com/en_GB/Marketing/i/logo/PayPal_logo_100x45.gif" border="0" alt="PayPal-Standard-Logo"><!-- PayPal Logo -->
</div>

	<div class="clear"></div>
		</div>
	</div>
</section>
<script>
	var dealTaxPercent = <?php echo $taxPercent; ?>;
	var dealSinglePrice = <?php echo $deal['Deal']['finalPrice'] ?>;
	var prepareForm = function(){
		var selectedQty = $("#DealOrderQuantity").val();
		var totalAmount = dealSinglePrice * selectedQty;
		var totalTaxAmount = ((totalAmount / 100) * dealTaxPercent);
		var totalAmountWithTax = totalAmount + totalTaxAmount;
		totalAmount = totalAmount.toFixed(2);
		totalTaxAmount = totalTaxAmount.toFixed(2);
		totalAmountWithTax = totalAmountWithTax.toFixed(2);
		$("#totalDealAmount").text('<?php echo $currencySymbol;?>'+totalAmount);
		$("#finalDealAmount").text('<?php echo $currencySymbol;?>'+totalAmountWithTax);
		$("#finalTaxAmount").text('<?php echo $currencySymbol;?>'+totalTaxAmount);
	};
	
	$(document).ready(function(){
		$("#DealOrderQuantity").change(prepareForm);
		prepareForm();
	});
</script>
